home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / snowbros.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  12KB  |  377 lines

  1. /***************************************************************************
  2.  
  3.  Snow Brothers
  4.  
  5.  driver by Mike Coates
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11. #include "cpu/m68000/m68000.h"
  12. #include "cpu/z80/z80.h"
  13.  
  14. static unsigned char *ram;
  15.  
  16. extern unsigned char *snowbros_spriteram;
  17.  
  18. void snowbros_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  19. WRITE_HANDLER( snowbros_spriteram_w );
  20. READ_HANDLER( snowbros_spriteram_r );
  21.  
  22.  
  23.  
  24. static int snowbros_interrupt(void)
  25. {
  26.     return cpu_getiloops() + 2;    /* IRQs 4, 3, and 2 */
  27. }
  28.  
  29.  
  30.  
  31. static READ_HANDLER( snowbros_input_r )
  32. {
  33.     int ans = 0xff;
  34.  
  35.     switch (offset)
  36.     {
  37.         case 0:
  38.             ans = (input_port_0_r (offset) << 8) + (input_port_3_r (offset));
  39.             break;
  40.         case 2:
  41.             ans = (input_port_1_r (offset) << 8) + (input_port_4_r (offset));
  42.             break;
  43.         case 4:
  44.             ans = input_port_2_r (offset) << 8;
  45.             break;
  46.     }
  47.  
  48.     return ans;
  49. }
  50.  
  51. /* Sound Routines */
  52.  
  53. READ_HANDLER( snowbros_68000_sound_r )
  54. {
  55.     int ret;
  56.  
  57.     /* If the sound CPU is running, read the YM3812 status, otherwise
  58.        just make it pass the test */
  59.     if (Machine->sample_rate != 0)
  60.     {
  61.         ret = soundlatch_r(offset);
  62.     }
  63.     else
  64.     {
  65.         ret = 3;
  66.     }
  67.  
  68.     return ret;
  69. }
  70.  
  71.  
  72. static WRITE_HANDLER( snowbros_68000_sound_w )
  73. {
  74.     soundlatch_w(offset,data);
  75.     cpu_cause_interrupt(1,Z80_NMI_INT);
  76. }
  77.  
  78.  
  79.  
  80. static struct MemoryReadAddress readmem[] =
  81. {
  82.     { 0x000000, 0x03ffff, MRA_ROM },
  83.     { 0x100000, 0x103fff, MRA_BANK1 },
  84.     { 0x300000, 0x300001, snowbros_68000_sound_r },
  85.     { 0x500000, 0x500005, snowbros_input_r },
  86.     { 0x600000, 0x6001ff, paletteram_word_r },
  87.     { 0x700000, 0x701dff, snowbros_spriteram_r },
  88.     { -1 }  /* end of table */
  89. };
  90.  
  91. static struct MemoryWriteAddress writemem[] =
  92. {
  93.     { 0x000000, 0x03ffff, MWA_ROM },
  94.     { 0x100000, 0x103fff, MWA_BANK1, &ram },
  95.     { 0x200000, 0x200001, watchdog_reset_w },
  96.     { 0x300000, 0x300001, snowbros_68000_sound_w },
  97. //    { 0x400000, 0x400001, snowbros_interrupt_enable_w },
  98.     { 0x600000, 0x6001ff, paletteram_xBBBBBGGGGGRRRRR_word_w, &paletteram },
  99.     { 0x700000, 0x701dff, snowbros_spriteram_w, &snowbros_spriteram, &videoram_size },
  100.     { 0x800000, 0x800001, MWA_NOP },    /* IRQ 4 acknowledge? */
  101.     { 0x900000, 0x900001, MWA_NOP },    /* IRQ 3 acknowledge? */
  102.     { 0xa00000, 0xa00001, MWA_NOP },    /* IRQ 2 acknowledge? */
  103.     { -1 }  /* end of table */
  104. };
  105.  
  106. static struct MemoryReadAddress sound_readmem[] =
  107. {
  108.     { 0x0000, 0x7fff, MRA_ROM },
  109.     { 0x8000, 0x87ff, MRA_RAM },
  110.     { -1 }  /* end of table */
  111. };
  112.  
  113. static struct MemoryWriteAddress sound_writemem[] =
  114. {
  115.     { 0x0000, 0x7fff, MWA_ROM },
  116.     { 0x8000, 0x87ff, MWA_RAM },
  117.     { -1 }  /* end of table */
  118. };
  119.  
  120. static struct IOReadPort sound_readport[] =
  121. {
  122.     { 0x02, 0x02, YM3812_status_port_0_r },
  123.     { 0x04, 0x04, soundlatch_r },
  124.     { -1 }    /* end of table */
  125. };
  126.  
  127. static struct IOWritePort sound_writeport[] =
  128. {
  129.     { 0x02, 0x02, YM3812_control_port_0_w },
  130.     { 0x03, 0x03, YM3812_write_port_0_w },
  131.     { 0x04, 0x04, soundlatch_w },    /* goes back to the main CPU, checked during boot */
  132.     { -1 }    /* end of table */
  133. };
  134.  
  135.  
  136.  
  137. INPUT_PORTS_START( snowbros )
  138.     PORT_START    /* 500001 */
  139.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY )
  140.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  141.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  142.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  143.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
  144.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
  145.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 )
  146.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* Must be low or game stops! */
  147.                                                /* probably VBlank */
  148.  
  149.     PORT_START    /* 500003 */
  150.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  151.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  152.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  153.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  154.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 | IPF_PLAYER2 )
  155.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 | IPF_PLAYER2 )
  156.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON3 | IPF_PLAYER2 )
  157.     PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  158.  
  159.     PORT_START    /* 500005 */
  160.     PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
  161.     PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 )
  162.     PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
  163.     PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_COIN2 )
  164.     PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
  165.     PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_TILT )
  166.     PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN3 )
  167.     PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
  168.  
  169.     PORT_START /* DSW 1 */
  170.     PORT_DIPNAME( 0x01, 0x01, "Country (Affects Coinage)" )
  171.     PORT_DIPSETTING(    0x01, "America" )
  172.     PORT_DIPSETTING(    0x00, "Europe" )
  173.     PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
  174.     PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
  175.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  176.     PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
  177.     PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
  178.     PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
  179.     PORT_DIPSETTING(    0x08, DEF_STR( On ) )
  180. /* Better to implement a coin mode 1-2 stuff later */
  181.     PORT_DIPNAME( 0x30, 0x30, "Coin A America/Europe" )
  182.     PORT_DIPSETTING(    0x10, "2C/1C 3C/1C" )
  183.     PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) )
  184.     PORT_DIPSETTING(    0x00, "2C/3C 4C/1C" )
  185.     PORT_DIPSETTING(    0x20, "1C/2C 2C/1C" )
  186.     PORT_DIPNAME( 0xc0, 0xc0, "Coin B America/Europe" )
  187.     PORT_DIPSETTING(    0x40, "2C/1C 1C/4C" )
  188.     PORT_DIPSETTING(    0xc0, "1C/1C 1C/2C" )
  189.     PORT_DIPSETTING(    0x00, "2C/3C 1C/6C" )
  190.     PORT_DIPSETTING(    0x80, "1C/2C 1C/3C" )
  191.  
  192.     PORT_START /* DSW 2 */
  193.     PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
  194.     PORT_DIPSETTING(    0x02, "Easy" )
  195.     PORT_DIPSETTING(    0x03, "Normal" )
  196.     PORT_DIPSETTING(    0x01, "Hard" )
  197.     PORT_DIPSETTING(    0x00, "Hardest" )
  198.     PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
  199.     PORT_DIPSETTING(    0x04, "100k and every 200k " )
  200.     PORT_DIPSETTING(    0x0c, "100k Only" )
  201.     PORT_DIPSETTING(    0x08, "200k Only" )
  202.     PORT_DIPSETTING(    0x00, "None" )
  203.     PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
  204.     PORT_DIPSETTING(    0x20, "1" )
  205.     PORT_DIPSETTING(    0x00, "2" )
  206.     PORT_DIPSETTING(    0x30, "3" )
  207.     PORT_DIPSETTING(    0x10, "4" )
  208.     PORT_BITX(    0x40, 0x40, IPT_DIPSWITCH_NAME | IPF_CHEAT, "Invulnerability", IP_KEY_NONE, IP_JOY_NONE )
  209.     PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
  210.     PORT_DIPSETTING(    0x00, DEF_STR( On ) )
  211.     PORT_DIPNAME( 0x80, 0x80, "Allow Continue" )
  212.     PORT_DIPSETTING(    0x00, DEF_STR( No ) )
  213.     PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
  214. INPUT_PORTS_END
  215.  
  216.  
  217.  
  218. static struct GfxLayout tilelayout =
  219. {
  220.     16,16,    /* 16*16 sprites */
  221.     4096,    /* 4096 sprites */
  222.     4,    /* 4 bits per pixel */
  223.     { 0, 1, 2, 3 },
  224.     {
  225.         0, 4, 8, 12, 16, 20, 24, 28,
  226.         8*32+0, 8*32+4, 8*32+8, 8*32+12, 8*32+16, 8*32+20, 8*32+24, 8*32+28,
  227.     },
  228.     {
  229.         0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32,
  230.         16*32, 17*32, 18*32, 19*32, 20*32, 21*32, 22*32, 23*32
  231.     },
  232.     128*8
  233. };
  234.  
  235. static struct GfxDecodeInfo gfxdecodeinfo[] =
  236. {
  237.     { REGION_GFX1, 0, &tilelayout,  0, 16 },
  238.     { -1 } /* end of array */
  239. };
  240.  
  241.  
  242.  
  243. /* handler called by the 3812 emulator when the internal timers cause an IRQ */
  244. static void irqhandler(int linestate)
  245. {
  246.     cpu_set_irq_line(1,0,linestate);
  247. }
  248.  
  249. static struct YM3812interface ym3812_interface =
  250. {
  251.     1,            /* 1 chip */
  252.     3579545,    /* 3.579545 MHz ? (hand tuned) */
  253.     { 100 },    /* volume */
  254.     { irqhandler },
  255. };
  256.  
  257.  
  258.  
  259. static struct MachineDriver machine_driver_snowbros =
  260. {
  261.     /* basic machine hardware */
  262.     {
  263.         {
  264.             CPU_M68000,
  265.             8000000,    /* 8 Mhz ????? */
  266.             readmem,writemem,0,0,
  267.             snowbros_interrupt,3
  268.         },
  269.         {
  270.             CPU_Z80 | CPU_AUDIO_CPU,
  271.             3600000,    /* 3.6 Mhz ??? */
  272.             sound_readmem,sound_writemem,sound_readport,sound_writeport,
  273.             ignore_interrupt,0    /* IRQs are caused by the YM3812 */
  274.         }
  275.     },
  276.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  277.     1,    /* 1 CPU slice per frame - interleaving is forced when a sound command is written */
  278.     0,
  279.  
  280.     /* video hardware */
  281.     32*8, 32*8, { 0*8, 32*8-1, 2*8, 30*8-1 },
  282.     gfxdecodeinfo,
  283.     256, 256,
  284.     0,
  285.  
  286.     VIDEO_TYPE_RASTER | VIDEO_SUPPORTS_DIRTY | VIDEO_MODIFIES_PALETTE,
  287.     0,
  288.     generic_vh_start,
  289.     generic_vh_stop,
  290.     snowbros_vh_screenrefresh,
  291.  
  292.     /* sound hardware */
  293.     0,0,0,0,
  294.     {
  295.         {
  296.             SOUND_YM3812,
  297.             &ym3812_interface
  298.         },
  299.     }
  300. };
  301.  
  302.  
  303.  
  304. /***************************************************************************
  305.  
  306.   Game driver(s)
  307.  
  308. ***************************************************************************/
  309.  
  310. ROM_START( snowbros )
  311.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 6*64k for 68000 code */
  312.     ROM_LOAD_EVEN( "sn6.bin",  0x00000, 0x20000, 0x4899ddcf )
  313.     ROM_LOAD_ODD ( "sn5.bin",  0x00000, 0x20000, 0xad310d3f )
  314.  
  315.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for z80 sound code */
  316.     ROM_LOAD( "snowbros.4",   0x0000, 0x8000, 0xe6eab4e4 )
  317.  
  318.     ROM_REGION( 0x80000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  319.     ROM_LOAD( "ch0",          0x00000, 0x20000, 0x36d84dfe )
  320.     ROM_LOAD( "ch1",          0x20000, 0x20000, 0x76347256 )
  321.     ROM_LOAD( "ch2",          0x40000, 0x20000, 0xfdaa634c )
  322.     ROM_LOAD( "ch3",          0x60000, 0x20000, 0x34024aef )
  323. ROM_END
  324.  
  325. ROM_START( snowbroa )
  326.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 6*64k for 68000 code */
  327.     ROM_LOAD_EVEN( "snowbros.3a",  0x00000, 0x20000, 0x10cb37e1 )
  328.     ROM_LOAD_ODD ( "snowbros.2a",  0x00000, 0x20000, 0xab91cc1e )
  329.  
  330.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for z80 sound code */
  331.     ROM_LOAD( "snowbros.4",   0x0000, 0x8000, 0xe6eab4e4 )
  332.  
  333.     ROM_REGION( 0x80000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  334.     ROM_LOAD( "ch0",          0x00000, 0x20000, 0x36d84dfe )
  335.     ROM_LOAD( "ch1",          0x20000, 0x20000, 0x76347256 )
  336.     ROM_LOAD( "ch2",          0x40000, 0x20000, 0xfdaa634c )
  337.     ROM_LOAD( "ch3",          0x60000, 0x20000, 0x34024aef )
  338. ROM_END
  339.  
  340. ROM_START( snowbrob )
  341.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 6*64k for 68000 code */
  342.     ROM_LOAD_EVEN( "sbros3-a",     0x00000, 0x20000, 0x301627d6 )
  343.     ROM_LOAD_ODD ( "sbros2-a",     0x00000, 0x20000, 0xf6689f41 )
  344.  
  345.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for z80 sound code */
  346.     ROM_LOAD( "snowbros.4",   0x0000, 0x8000, 0xe6eab4e4 )
  347.  
  348.     ROM_REGION( 0x80000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  349.     ROM_LOAD( "ch0",          0x00000, 0x20000, 0x36d84dfe )
  350.     ROM_LOAD( "ch1",          0x20000, 0x20000, 0x76347256 )
  351.     ROM_LOAD( "ch2",          0x40000, 0x20000, 0xfdaa634c )
  352.     ROM_LOAD( "ch3",          0x60000, 0x20000, 0x34024aef )
  353. ROM_END
  354.  
  355. ROM_START( snowbroj )
  356.     ROM_REGION( 0x40000, REGION_CPU1 )    /* 6*64k for 68000 code */
  357.     ROM_LOAD_EVEN( "snowbros.3",   0x00000, 0x20000, 0x3f504f9e )
  358.     ROM_LOAD_ODD ( "snowbros.2",   0x00000, 0x20000, 0x854b02bc )
  359.  
  360.     ROM_REGION( 0x10000, REGION_CPU2 )    /* 64k for z80 sound code */
  361.     ROM_LOAD( "snowbros.4",   0x0000, 0x8000, 0xe6eab4e4 )
  362.  
  363.     ROM_REGION( 0x80000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  364.     /* The gfx ROM (snowbros.1) was bad, I'm using the ones from the other sets. */
  365.     ROM_LOAD( "ch0",          0x00000, 0x20000, 0x36d84dfe )
  366.     ROM_LOAD( "ch1",          0x20000, 0x20000, 0x76347256 )
  367.     ROM_LOAD( "ch2",          0x40000, 0x20000, 0xfdaa634c )
  368.     ROM_LOAD( "ch3",          0x60000, 0x20000, 0x34024aef )
  369. ROM_END
  370.  
  371.  
  372.  
  373. GAME( 1990, snowbros, 0,        snowbros, snowbros, 0, ROT0, "Toaplan (Romstar license)", "Snow Bros. - Nick & Tom (set 1)" )
  374. GAME( 1990, snowbroa, snowbros, snowbros, snowbros, 0, ROT0, "Toaplan (Romstar license)", "Snow Bros. - Nick & Tom (set 2)" )
  375. GAME( 1990, snowbrob, snowbros, snowbros, snowbros, 0, ROT0, "Toaplan (Romstar license)", "Snow Bros. - Nick & Tom (set 3)" )
  376. GAME( 1990, snowbroj, snowbros, snowbros, snowbros, 0, ROT0, "Toaplan (Romstar license)", "Snow Bros. - Nick & Tom (Japan)" )
  377.